﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;

namespace WoChu.RfClient.Duty
{
    public class OnShelvesUIRule
    {
        private static OnShelvesUIRule _NewInstance = new OnShelvesUIRule();

        public static OnShelvesUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new OnShelvesUIRule();
                }

                return _NewInstance;
            }
        }

        public ResultModel<LocationGoodsInfo> GetLocationGoodsInfo(string barCode)
        {
            try
            {
                 var _result= WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOnShelves>.NewInstance.InvokeWebMethod<ResultModel< LocationGoodsInfo>>("GetLocationGoodsInfo", new object[] { barCode});
                 if (_result == null)
                     return new ResultModel<LocationGoodsInfo>().GetInstance();
                 return _result;  
               
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }

        public ResultModel<bool> SetOnShelves(string userID,string objType, List<LocationGoodsInfo> lstLocationGoods)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOnShelves>.NewInstance.InvokeWebMethod<List<LocationGoodsInfo>, ResultModel<bool>>("SetOnShelves", new object[] { userID, objType }, lstLocationGoods);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;  
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }
        //GET OnShelves/CheckOnShelvesGoodsQTY?GoodsCode={GoodsCode}&qty={qty}
        public ResultModel<bool> CheckOnShelvesGoodsQTY(string GoodsCode, int qty)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IOnShelves>.NewInstance.InvokeWebMethod<ResultModel<bool>>("CheckOnShelvesGoodsQTY", new object[] { GoodsCode, qty });
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return null;
        }
    }
}
